package pers.zhxu.extNLPM.estimation;

import pers.zhxu.extNLPM.util.Edge;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class NLPM {

    public static final int CN = 0;

    private static final int k = 3;

    public static float measureCalc(List<Edge> edge1, List<Edge> edge2, Calendar start, int type){
        float measure = 0.f;
        if(type==CN)
            measure = cn_wt(edge1, edge2, start);
        return measure;
    }

    private static float cn_wt(List<Edge> edge1, List<Edge> edge2, Calendar start){
        float result = 0.f;
        List<Edge> edges = new ArrayList<>();
        edges.addAll(edge1);
        edges.addAll(edge2);
        for(Edge edge: edges){
            result += timeDecay(edge.time(), start) * edge.weight();
        }

        return result;
    }

    private static float timeDecay(Calendar time, Calendar start){
        return (float) Math.log(time.get(Calendar.YEAR) - start.get(Calendar.YEAR) + k);
    }
}
